﻿using JetBrains.Annotations;
using Missbot.Service;
using MissRobot.Migrator.SourceMongo;

namespace MissRobot.Migrator.Migrators
{
    [UsedImplicitly]
    public class OSPersonMig : IMigrator
    {
        public void Migrate(long QQNum, string UserID)
        {
            var osPerson = SourceMongoService<OSPerson>.GetOnly(p => p.QQNum == QQNum);
            osPerson.UserID = UserID;
            osPerson.Id     = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
            MongoService<Missbot.AIModule.OnlineStore.OSPerson>.DeleteMany(p => p.UserID == UserID);
            MongoService<Missbot.AIModule.OnlineStore.OSPerson>.Insert(osPerson);
        }
    }
    
    public class OSPerson : Missbot.AIModule.OnlineStore.OSPerson
    {
        public long QQNum { get; set; }
    }
}